﻿@{
    ViewBag.Title = "Manage User Roles";
}

<h2>Admin Panel | Manage User Roles</h2>
@Html.ActionLink("Manage Roles", "Index")  | @Html.ActionLink("Manage User Roles", "ManageUserRoles", "", new { style = "font-weight:bold;" }) | @Html.ActionLink("Manage Users", "ManageUsers")
<hr />

<h3>Role Add to User</h3>

@using (Html.BeginForm("RoleAddToUser", "Admin"))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <p>
        Username: @Html.DropDownList("UserName", (IEnumerable<SelectListItem>)ViewBag.Users, "Select user ...")
        Role Name: @Html.DropDownList("RoleName", (IEnumerable<SelectListItem>)ViewBag.Roles, "Select role ...")

    </p>

    <input type="submit" value="Save" />
}
<hr />
<h3>Get Roles for a User</h3>
@using (Html.BeginForm("GetRoles", "Admin"))
{
    @Html.AntiForgeryToken()
    <p>
        Username: @Html.DropDownList("UserName", (IEnumerable<SelectListItem>)ViewBag.Users, "Select user ...")
        <input type="submit" value="Get Roles for this User" />
    </p>
}

@if (ViewBag.RolesForThisUser != null)
{
    <div style="background-color:yellow;">
        <h3>Roles for this user </h3>
        <ol>
            @foreach (string s in ViewBag.RolesForThisUser)
            {
                <li>@s</li>
            }
        </ol>
    </div>
}

<hr />
<h3>Delete A User from a Role</h3>

@using (Html.BeginForm("DeleteRoleForUser", "Admin"))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <p>
        Username: @Html.DropDownList("UserName", (IEnumerable<SelectListItem>)ViewBag.Users, "Select user ...")
        Role Name: @Html.DropDownList("RoleName", (IEnumerable<SelectListItem>)ViewBag.Roles, "Select role ...")

    </p>

    <input type="submit" value="Delete this user from Role" />
}

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
